package com.hemerasolutions.v2trainer.model.step.substep;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

import com.hemerasolutions.v2trainer.model.base.BaseModel;
import com.hemerasolutions.v2trainer.model.step.Step;
import com.hemerasolutions.v2trainer.model.training.Training;


@Entity
public class SubTrainingStep extends BaseModel {

	private static final long serialVersionUID = 1L;
	
    @Column
    private int level = 0;

    @OneToOne
    private Step step;

    @ManyToOne
	private Training subTraining;

	
	public SubTrainingStep (){
		super();
	}


	public Training getSubTraining() {
		return subTraining;
	}


	public void setSubTraining(Training subTraining) {
		this.subTraining = subTraining;
	}


	public int getLevel() {
		return level;
	}


	public void setLevel(int level) {
		this.level = level;
	}


	public Step getStep() {
		return step;
	}


	public void setStep(Step step) {
		this.step = step;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + level;
		result = prime * result + ((step == null) ? 0 : step.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (!super.equals(obj)) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		SubTrainingStep other = (SubTrainingStep) obj;
		if (level != other.level) {
			return false;
		}
		if (step == null) {
			if (other.step != null) {
				return false;
			}
		} else if (!step.equals(other.step)) {
			return false;
		}
		return true;
	}


	@Override
	public String toString() {
		return "SubTrainingStep [level=" + level + ", step=" + step + "]";
	}
	
	
}
